set -e -u 
# check for options with arguments
Usage() {
    echo 'this is the help'
    exit 1
}
length=0
BW=False
RES=100
while [ $# -gt 0 ]
do
    case "$1" in
        
	--)     shift; break;;          # ====> standard in
	-h)     Usage;;                 # ==> Help message.
        --help) Usage;;
        --bw)  BW=True;;
        --res) shift; RES=$1;;
	-*)     Usage;;                 # ===> illegal help
         *)     Usage;;			# first argument not legal
    esac   
    shift
done

cd charts
(
cat << EOF
lwd=3
font_size = .8
tick_multiplier = 1
lwd_grid = .3
width=5.5
margins=c(4, 4, .5, 0.5) 
mgp = c(4, 1, 0)
legend_font_size = 0.8
default_grid_color = "lightgray"
ax_col = default_grid_color
box_col = default_grid_color
rec_col = default_grid_color
bar_label_size = .8
margins_bar=c(2, 4, .5, 0.5) 
base_line_type = 2
months.font = .6
at = c(0,1,2,3,4,5,6,7,8,9,10,11,12)
at = at /12 * 52
months = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
at2 = c(0,1,2,3,4,5,6,7,8,9,10,11)
at2 = at2 /12 * 52
at2 = at2 + .5 * 52/12
months.grid = T
make.title= F
bottom.margin = 4
top.margin=.5
box.lwd=1
line_types = c(1,1,1,1,1,1)
line_colors = c("red","blue", "green", "orange")
bar_color = c("#330099", "#FF6600")
base_line_col = "green"
base_line_col = c(654)
EOF
) > .Rprofile

echo res = $RES >> .Rprofile

if [ "$BW" == "True" ]; then
(
cat << EOF
line_types = c(2,1,3,4,5,6)
line_colors = c(rep("black", 10))
bar_color = c("black", "lightgray")
base_line_col = "black"
EOF
) >> .Rprofile
fi
cd ..
